Java with Traits — Improving Opportunities for Reuse
نویسندگان
چکیده
The Java language includes features that present significant barriers to reuse; in practice, programmers have no choice but to copy and paste code that is not accessible via inheritance. Traits improve code-sharing in Smalltalk by providing a means to reuse such behavior, and we claim that a similar mechanism for Java would overcome not just the lack of multiple inheritance but Java’s other barriers to reuse as well, including the use of private, final and synchronized qualifiers. In support of our claim we present the initial findings of a case study of Java Swing, a large production-quality library, showing how we isolated pieces of duplicated code that could not be eliminated by conventional means and how traits could be used to eliminate them.
منابع مشابه
Java Traits — Improving Opportunities for Reuse
One goal of Object-Oriented Programming is to enable programmers to craft elegant and reusable systems. In practice however, Java programmers have no choice but to copy and paste code that cannot be shared via inheritance. The resulting duplication makes systems difficult to understand and hard to maintain. Traits are a language feature, originally prototyped in Smalltalk, that directly address...
متن کاملTraitRecordJ: A programming language with traits and records
Traits have been designed as units for fine-grained reuse of behavior in the object-oriented paradigm. Records have been devised to complement traits for fine-grained reuse of state. In this paper, we present the language TRAITRECORDJ, a JAVA dialect with records and traits. Records and traits can be composed by explicit linguistic operations, allowing code manipulations to achieve fine-grained...
متن کاملA Study of Code Reuse and Sharing Characteristics of Java Applications
This paper presents a detailed characterization of Java application and applet workloads in terms of reuse and sharing of Java code at the program, class, and method level. In order to expose more sharing opportunities, techniques for detecting code equivalence even in the presence of minor code changes or constant pool index differences are also proposed and examined. The analyzed application ...
متن کاملOn Traits and Types in a Java-like Setting
Both single and multiple class-based inheritance are often inappropriate as a reuse mechanism, because classes play two competing roles. Namely, a class is both a generator of instances and a unit of reuse. Traits are composable pure units of behavior reuse, consisting only of methods, that have been proposed as an add-on to single class-based inheritance in order to improve reuse. However, ado...
متن کاملImplementing type-safe software product lines using parametric traits
A software product line (SPL) is a set of related software systems with well-defined commonality and variability that are developed by reusing common artifacts. In this paper, we present a novel technique for implementing SPLs by exploiting mechanisms for fine-grained reuse which are orthogonal to class-based inheritance. In our approach the concepts of type, behavior, and state are separated i...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2004